﻿using QueuesClients;
using QueuesClients.KioskNotifService;
using QueuesLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace QueuesClients {
    public class Kiosk : QueuesClient<KioskNotifServiceClient, KioskNotifService.KioskNotifService>, IQueuesClient {

        public Kiosk(string id, string ipAddress, string port, string endAddr) :
            base(id, ipAddress, port, endAddr) {
            proxy = new KioskNotifServiceClient("KioskNotifService", this.Url);
        }

        public override KioskNotifServiceClient Proxy {
            get { return proxy; }
        }

        public async Task<string> InitializeAsync(List<Subject> subjects, List<Counter> counters, List<QueueInfo> tickets) {
            try {
                var resp = await Proxy.initializeAsync(subjects, counters, tickets);
                Proxy.Close();
                return resp;
            }
            catch {
                Proxy.Abort();
                throw;
            }
        }

        public async Task<string> UpdateAllAsync(List<Counter> counters, List<QueueInfo> tickets) {
            try {
                var resp = await Proxy.updateAsync(counters, tickets);
                Proxy.Close();
                return resp;
            }
            catch {
                Proxy.Abort();
                throw;
            }
        }


        public string Initialize(List<Subject> subjects, List<Counter> counters, List<QueueInfo> tickets) {
            throw new NotImplementedException();
        }
    }
}